Google Cloud Network Peering allows you to establish private, high-bandwidth connections between virtual networks in the same or different Google Cloud projects. This enables communication between resources in different networks as if they were part of the same network, without using external IP addresses.
Private Connectivity:
Here's a basic example of setting up Network Peering between two Google Cloud projects:
Enable API and Set Up Projects:
bashgcloud compute networks create network-a --project=project-a gcloud compute networks create network-b --project=project-b
bashgcloud compute networks subnets create subnet-a --network=network-a --project=project-a --region=us-central1 --range=10.1.0.0/24 gcloud compute networks subnets create subnet-b --network=network-b --project=project-b --region=us-central1 --range=10.2.0.0/24
bashgcloud compute networks peerings create peering-a-to-b --project=project-a --network=network-a --peer-project=project-b --peer-network=network-b --auto-create-routes gcloud compute networks peerings create peering-b-to-a --project=project-b --network=network-b --peer-project=project-a --peer-network=network-a --auto-create-routes
bashgcloud compute firewall-rules create allow-internal-a-to-b --project=project-a --network=network-a --allow=INTERNAL --source-ranges=10.2.0.0/24 gcloud compute firewall-rules create allow-internal-b-to-a --project=project-b --network=network-b --allow=INTERNAL --source-ranges=10.1.0.0/24
Always refer to the official documentation for the most up-to-date and detailed information on configuring Google Cloud Network Peering. Adjust the commands based on your specific requirements, such as region, IP ranges, and firewall rules.